﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebHoiChoMuaBan.Models
{
    public class NodeMenu
    {
        private String nodeName;
        private String nodeID;
        private String nodeLink;
        private List<NodeMenu> listNodeChild;

        public NodeMenu()
        {
            this.nodeName = String.Empty;
            this.nodeID = String.Empty;
            this.nodeLink = String.Empty;
            this.listNodeChild = new List<NodeMenu>();
        }

        public NodeMenu(String nodeID, String nodeName)
        {
            this.nodeName = nodeName;
            this.nodeID = nodeID;
            this.nodeLink = String.Empty;
            this.listNodeChild = new List<NodeMenu>();
        }

        public NodeMenu(String nodeID, String nodeName, String link)
        {
            this.nodeName = nodeName;
            this.nodeID = nodeID;
            this.nodeLink = link;
            this.listNodeChild = new List<NodeMenu>();
        }

        public String NodeName
        {
            get { return nodeName; }
            set { nodeName = value; }
        }
        
        public String NodeID
        {
            get { return nodeID; }
            set { nodeID = value; }
        }
        
        public String NodeLink
        {
            get { return nodeLink; }
            set { nodeLink = value; }
        }

        public List<NodeMenu> ListNodeChild
        {
            get { return listNodeChild; }
            set { listNodeChild = value; }
        }
    }

    public class MenuLeft
    {
        private List<NodeMenu> nodes;

        public MenuLeft()
        {
            this.nodes = new List<NodeMenu>();
        }

        public List<NodeMenu> GetNodes()
        {
            return this.nodes;
        }

        public NodeMenu Nodes(int index)
        {
            return this.nodes[index];
        }

        public NodeMenu Nodes(String nodeName)
        {
            NodeMenu nodeFind = null;

            foreach (NodeMenu node in this.nodes)
            {
                if (node.NodeName.Equals(nodeName))
                {
                    nodeFind = node;
                    break;
                }
            }

            return nodeFind;
        }

        public void AddNode(NodeMenu node)
        {
            this.nodes.Add(node);
        }

        public void RemoveNode(NodeMenu node)
        {
            this.nodes.Remove(node);
        }

        public void RemoveNode(int index)
        {
            this.nodes.RemoveAt(index);
        }

        public void RemoveAll()
        {
            this.nodes.Clear();
        }

        public int Count
        {
            get { return this.nodes.Count; }
        }
    }
}